package com.audi.view;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;

import com.audi.R;

public class AudiDialog extends Dialog {

	Context mContext;
	Rect displayRectangle;
	float widthSize = 0.7f;

	public AudiDialog(Context context, int theme) {
		super(context);
		init(context);
	}

	public AudiDialog(Context context) {
		super(context);
		init(context);
	}

	private void init(Context context) {
		this.mContext = context;
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		displayRectangle = new Rect();
		Window window = getWindow();
		window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle);
		this.getWindow().setBackgroundDrawable(
				new ColorDrawable(android.graphics.Color.TRANSPARENT));
	}

	public void setLayout(int resourceLayout) {
		LayoutInflater inflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View layout = inflater.inflate(resourceLayout, null);
		layout.setMinimumWidth((int) (displayRectangle.width() * widthSize));
		layout.setBackgroundResource(R.drawable.background_dialog);
		setContentView(layout);
	}
}
